package com.lbn.monitor.util;

import android.content.Context;
import android.os.Environment;

import java.io.File;

/**
 * Created by Administrator on 2016/9/5.
 */
public class FileUtils {

    private FileUtils(){};

    private static Context mContext;

    public static void init(Context context){
        mContext = context;
    }

    public static String getCacheDir(){
        return mContext.getCacheDir().getPath();
    }


    public static String getSDPath(){

        if(hasSdcard()){

            String path = Environment.getExternalStorageDirectory().getPath()+ File.separator+"Android"+ File.separator+"data"+ File.separator+"com.gzgroup.roro";
            File file = new File(path);
            if(!file.exists()){
                file.mkdirs();
            }
            return path;
        }
        return getCacheDir();
    }

    /**
     * 判断sdcard是否存在
     */
    public static boolean hasSdcard() {
        // 判断Sdcard是否可用
        if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
            return true;
        } else
            return false;
    }


}
